<template>
  <div class="register2-page">
    <div class="register2-headline">个人信息（必填）</div>
    <div class="register2-subhead">为保证平台求职环境真实性，需要完成行业注册人员认证，平台对人才信息保密，未授权不向第三方开放</div>
    <div class="register2-form">
      <el-row>
        <el-col :span="12">
          <el-form label-position="right" label-width="140px" :model="params">
            <el-form-item label="姓名">
              <el-col :span="13">
                <el-input class="theme-input name-input" v-model="params.name"></el-input>
              </el-col>
              <el-col :span="11">
                <el-radio-group size="mini" v-model="params.sex">
                  <el-radio :label="0" value="0">男</el-radio>
                  <el-radio :label="1" value="1">女</el-radio>
                </el-radio-group>
              </el-col>
            </el-form-item>

            <el-form-item label="开始工作年份">
              <el-date-picker
                :editable="false"
                placeholder="请选择"
                type="year"
                v-model="params.workDay"
              ></el-date-picker>
            </el-form-item>

            <el-form-item label="当前年薪">
              <el-col :span="13" style="font-size:20px;">
                <el-input class="theme-input money-input" v-model="params.salaryPerMonth"></el-input>&nbsp;W/&nbsp;
                <el-input class="theme-input money-input" v-model="params.monthCount"></el-input>&nbsp;年
              </el-col>
              <el-col :span="11">
                <el-radio-group size="mini" v-model="params.tax">
                  <el-radio :label="0" value="0">税前</el-radio>
                  <el-radio :label="1" value="1">税后</el-radio>
                </el-radio-group>
              </el-col>
            </el-form-item>
            <el-form-item label="求职状态">
              <el-select v-model="params.jobState" placeholder="请选择求职状态">
                <el-option
                  v-for="(item,index) in data.allJobIntentionList"
                  :label="item.content"
                  :value="item.id"
                  :key="index"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :span="12">
          <el-form label-position="right" label-width="140px" :model="params">
            <el-form-item label="出生年份">
              <el-date-picker
                :editable="false"
                placeholder="请选择"
                type="year"
                v-model="params.birth"
              ></el-date-picker>
            </el-form-item>
            <el-form-item label="所在城市">
              <el-cascader
                class="register-cascader"
                :options="city"
                @change="getData"
                placeholder="所在城市"
                v-model="workCity"
              ></el-cascader>
            </el-form-item>
            <el-form-item label="电子邮箱">
              <el-input v-model="params.email" class="theme-input w300" placeholder="请输入电子邮箱"></el-input>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </div>
    <div style="display:flex;justify-content: center;margin:35px 0 0 0;">
      <el-button class="theme-button next-button" @click="doThird">下一步</el-button>
    </div>
  </div>
</template>
<script>
import validate from '../../assets/utils/validate.js'
import { chinaOptions, CodeToText, TextToCode } from '@/assets/utils/china.js'
export default {
  props: ['params', 'data'],
  data() {
    return {
      city: chinaOptions,
      workCity: []
    }
  },
  methods: {
    check() {
      if (this.params.name == '') {
        _g.message('请输入姓名', 'warning')
        return false
      }
      if (this.params.workDay == '') {
        _g.message('请选择工作年份', 'warning')
        return false
      }
      if (this.params.salaryPerMonth == '' || this.params.monthCount == '') {
        _g.message('请输入薪资情况', 'warning')
        return false
      }
      if (this.params.jobState == '') {
        _g.message('请选择求职状态', 'warning')
        return false
      }
      if (this.params.birth == '') {
        _g.message('请选择出生年份', 'warning')
        return false
      }
      if (this.params.city == '') {
        _g.message('请选择所在城市', 'warning')
        return false
      }
      if (this.params.email == '' || !validate.isEmail(this.params.email)) {
        _g.message('请输入正确的电子邮箱', 'warning')
        return false
      }
      return true
    },
    doThird() {
      //验证跳转到第三个页面
      if (!this.check()) return false
      this.$emit('input', 2)
    },
    getData(val) {
      // let l = []
      // for (let i in val) {
      //   l.push(CodeToText[val[i]])
      // }
      this.params.city = val.join('-')
    }
  },
  mounted() {},
  components: {}
}
</script>

<style lang="scss" scoped>
.next-button {
  width: 506px;
  height: 55px;
  border-radius: 5px;
  font-size: 28px;
  font-weight: 400;
  color: #fff;
  text-shadow: 0px 2px 2px rgba(0, 0, 0, 0.5);
}
</style>
